# _*_ coding: UTF-8 _*_
# @Time     : 2021/2/24 下午 01:59
# @Author   : Li Jie
# @Site     : http://www.hzdledu.com/
# @File     : thread_test2.py
# @Software : PyCharm

import threading
import time


# 继承Thread类创建线程
class SubThread(threading.Thread):
    def run(self) -> None:
        for i in range(3):
            time.sleep(1)
            print(f'线程名:{threading.current_thread().name}执行第{i}次')  # 打印线程名和运行次数


def thread_main():
    print(f'-------主线程开始-------')
    t1 = SubThread()  # 创建线程1
    t2 = SubThread()  # 创建线程2
    t1.start()  # 启动线程1
    t2.start()  # 启动线程2
    t1.join()  # 等待线程1结束
    t2.join()  # 等待线程2结束
    print(f'-------主线程开始-------')


if __name__ == '__main__':
    thread_main()
